﻿using System.ComponentModel;
using System.Linq;
using EFMock.Test.Shared;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace EFMock.Test.Introduction
{
	[TestClass]
	public class UnitTest1
	{
		NorthwindContext db;

		[ClassInitialize]
		void ClassInitialize()
		{
			db = ContextFactory.Mock<NorthwindContext>();
		}

		[TestMethod]
		[Category("Where")]
		[Microsoft.VisualStudio.TestTools.UnitTesting.Description("This sample uses WHERE to filter for Customers in London.")]
		public void LinqToSqlWhere01()
		{
            db.Customers.Add(new Customer { City = "London" });
            db.Customers.Add(new Customer { City = "NotLondon" });
            
            var q = (
				from c in db.Customers
				where c.City == "London"
				select c).ToList();

            Assert.AreEqual(1, q.Count());
            Assert.AreEqual("London", q[0].City);
		}
	}
}
